<template>
	<page-meta :root-font-size="fontSize"></page-meta>
	<view>
		<view class="bg-main" style="">
			<view class="status_bar" style="height: 20rpx;"></view>
			<view class="flex flex-ac flex-bt fc-f">
				<h-navigateBack></h-navigateBack>
				<text style="font-size: 38rpx;">改签</text>
				<view></view>
			</view>
			<view class="status_bar" style="height: 20rpx;"></view>
		</view>
		<!-- 弹出层：车票数据 -->
		<view style="height: 1100rpx;margin-top: 10rpx;">
			<!-- 时间选项卡 -->
			<view class="headerClass">
				<scroll-view class="scrollClass" scroll-x :scroll-into-view="scrollToView" scroll-with-animation="true">
					<view class="blockClass" :class="selectIndex == index ? 'dateselect': '' "
						v-for="(item,index) in dateArray" :key="index" @click="dateClick(index,item)"
						v-model="selectIndex">
						<view class="textCLass jh_fs_26" :id="'view' + index">
							<view class="weekClass" :style="{color:selectIndex == index ? '#FFFFFF' : '#333333'}">
								{{item.week}}
							</view>
							<view class="dateClass" :style="{color:selectIndex == index ? '#FFFFFF' : '#333333'}">
								{{item.date}}
							</view>
						</view>
					</view>
				</scroll-view>
				<view style="width: 14%;height: 100%; align-items: center; justify-content: center;display: flex;">
					<image src="../static/order/calendar.png" class="calendarImage" @click="onShowDatePicker()">
					</image>
				</view>
			</view>
			<scroll-view style="height: 900rpx;margin-left: 36rpx;" :scroll-y="true">
				<view class="flex-bt flex-ac"
					style="border-bottom: solid 1rpx #DCDCDC;padding: 30rpx 10rpx 20rpx 10rpx;"
					v-for="(item,index) in shiftList" :key="index">

					<view class="flex">
						<view class="flex-ac">
							<view style="margin-left: 15rpx;">
								<view class="fc-main fs-36" style="display: flex;align-items: center;">
									<image src="../../static/order/xianlu.png" style="width: 35rpx;height: 35rpx;">
									</image>
									<view style="margin-left: 10rpx;font-size: 34rpx;">{{item.LineName}}</view>
								</view>
								<view class="fc-main fs-36"
									style="display: flex;align-items: center;flex-direction: column;">
									<view class="fc-main fs-36"
										style="display: flex;align-items: center;margin-top: 5rpx;">
										<view style="display: flex; width: 550rpx;">
											<view class="jh_u-f-ac">
												<image src="../static/order/time.png"
													style="width: 35rpx;height: 35rpx;">
												</image>
												<view style="margin-left: 10rpx;">{{timeFormat(item.SetoutTime)}}</view>
											</view>
											<view class="jh_u-f-ac" style="margin-left: 30rpx;">
												<image src="../static/order/freeTicket.png"
													style="width: 42rpx;height: 32rpx;"></image>
												<text style="margin-left: 10rpx;">余{{item.FreeSeats}}张</text>
											</view>
											<text class="fs-30"
												style="margin-left: 30rpx;color: #F35A46;">¥ <text
													style="font-size: 40rpx;color: #F35A46;">{{item.FullPrice}}起</text>
											</text>
										</view>
										<view class="checkbox" :class="item.checked ? 'checkbox-activite' : ''"
											@click="ticketSelect(index)">
											<u-icon name="checkmark" color="#FFF" size="32"></u-icon>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

				</view>
				<u-empty text="无班次信息" v-if="shiftList.length == 0"></u-empty>
			</scroll-view>
			<!-- <scroll-view style="height: 1000rpx;margin-left: 36rpx;" :scroll-y="true">
				<view class="flex-bt flex-ac"
					style="border-bottom: solid 1rpx #DCDCDC;padding: 30rpx 10rpx 20rpx 10rpx;"
					v-for="(item,index) in shiftList" :key="index">

					<view class="flex">
						<view class="flex-ac">
							<view style="margin-left: 15rpx;">
								<view class="fc-main fs-36" style="display: flex;align-items: center;">
									<image src="../../static/order/xianlu.png" style="width: 35rpx;height: 35rpx;">
									</image>
									<view style="margin-left: 10rpx;font-size: 34rpx;">{{item.LineName}}</view>
								</view>
								<view class="fc-main fs-36"
									style="display: flex;align-items: center;flex-direction: column;">
									<view class="fc-main fs-36"
										style="display: flex;align-items: center;margin-top: 5rpx;">
										<view style="display: flex; width: 550rpx;">
											<view class="jh_u-f-ac">
												<image src="../static/order/time.png"
													style="width: 35rpx;height: 35rpx;">
												</image>
												<view style="margin-left: 10rpx;">{{timeFormat(item.SetoutTime)}}</view>
											</view>
											<view class="jh_u-f-ac" style="margin-left: 30rpx;">
												<image src="../static/order/freeTicket.png"
													style="width: 42rpx;height: 32rpx;"></image>
												<text style="margin-left: 10rpx;">余{{item.FreeSeats}}张</text>
											</view>
											<text v-if="!item.checked" class="fs-30"
												style="margin-left: 30rpx;color: #F35A46;">¥ <text
													style="font-size: 40rpx;color: #F35A46;">{{item.FullPrice}}起</text>
											</text>
										</view>
										<view style="width:50rpx; margin-right 10rpx;" class="checkbox"
											:class="item.checked ? 'checkbox-activite' : ''"
											@click="ScheduleClike(index)">
										</view>
									</view>

								</view>
							</view>

						</view>


					</view>
					<view v-if="item.checked" style="background-color: #FFFFFF;width: 90%;">
						<view class="jh_u-f-ajb" style="margin: 20rpx;border-bottom: 1rpx solid #EAEAEA;"
							v-for="(itemType,indexType) in item.SchedulesType" :key="indexType">

							<text class="fs-30" style="color: #F35A46;">¥ <text
									style="font-size: 52rpx;color: #F35A46;">{{itemType.FullPrice}}</text>
							</text>
							<text style="font-size: 24rpx;color: #F35A46;margin-top: 30rpx;">
								<text v-if="itemType.Descript">
									{{itemType.Descript}}
								</text>
								<text v-if="!itemType.Descript">
									普通购票
								</text>
							</text>
							<view
								style="width: 120rpx;height: 60rpx;background: linear-gradient(270deg, #FF423F, #FF763F);border-radius: 30rpx;color: #FFFFFF;display: flex;align-items: center;justify-content: center;"
								@click="ticketTypeSelect(index,indexType)">
								改签
							</view>
						</view>
					</view>
				</view>
				<u-empty text="无班次信息" v-if="shiftList.length == 0"></u-empty>
			</scroll-view> -->
		</view>
		<view class="bg-main fc-f fs-34" hover-class="u-hover-class" @click="ticketTypeSelect"
			style="text-align: center;padding: 30rpx 340rpx ;border-radius: 200rpx;position: fixed;bottom: 20rpx;">
			确定
		</view>

		<view style="height: 30rpx;"></view>

		<u-toast ref="uToast"></u-toast>
		<!-- 日历 -->
		<uni-calendar ref="calendar" lunar="true" :insert="false" @confirm="confirm"></uni-calendar>
	</view>
</template>

<script>
	import {
		callWithErrorHandling
	} from "vue";
	var _self;
	var app = getApp().globalData;
	export default {
		data() {
			return {
				personArr: [],
				phone: '', //联系电话
				remark: '', //备注
				isCheckInsurance: false,
				insurance: 2, //保险价格
				isInsure: false,
				isCheckNotice: true,
				showNotice: false,
				showFreeChild: false,
				showTimePick: false,
				freeValue: 1,
				scrollToView: '',
				date: '', //时间轴上选中的日期
				recommendGeton: '', //推荐上车点
				list: [{
						name: '今天'
					},
					{
						name: '明天'
					},
					{
						name: '后天'
					}
				],
				current: 0,
				fontSize: '', //字体大小
				orderInfo: [], //订单信息
				startStation: '', //起点--接口查询字段
				endStation: '', //终点--接口查询字段
				ExecuteScheduleID: '',
				startGeocoderAddress: '', //实际上车点
				endGeocoderAddress: '', //实际下车点
				ActualStartSiteName: '', //起点--推荐上车字段
				ActualEndSiteName: '', //终点--推荐下车字段
				ActualStartTime: '',
				ActualEndTime: '',
				EstimatedTime: 0,
				PlanStartSiteName: '', //乘客选择字段
				PlanEndSiteName: '', //乘客选择字段
				userInfo: [], //用户信息
				ticketNum: 0, //票数
				idNameTypeStr: '', //乘客信息：拼接成字符串
				childrenNum: 0, //携童数
				adultNum: 0, //成人数
				freeTicketNum: 0, //免票数
				addOrderInfo: [], //添加订单
				paymentData: [], //支付信息数组
				timer: '', //定时器
				dateArray: [], //时间轴数组
				selectIndex: '', //选中下标
				dateShow: false, //是否显示日历
				shiftList: [], //班次列表
				Price: 0, //顶部显示的价格
				totalPrice: 0, //总价
				PriceID: '', //价格ID，下单时需要
				FreeSeats: '',
				ticketCheck: [], //确认
				currentType: '', //当前是什么模式：车站班车、城际快车、定制巴士
				startLineSite: [], //上车点数组
				currentLongitude: '', //乘客当前经度
				currentLatitude: '', //乘客当前纬度
				openid: '',
				LinePrices: [],
				FullPrice: '',
				HalfPrice: '',
				noticeContent: '',
				flowID: '', //支付流程ID
				checkTicketTimer: '', //确认订单状态定时器
				HotLine: '', //热线
				BookType: '', //记录当前是城际快车还是汽车票
				isStationChange: false, //判断是否有更换站点，站点更换之后做不一样的发车提示
				freeMax: 1,
				freeCountChange: 1,
				freeCount: 0, //携童免票数量
				freeChildtitle: '免费携童',
				CarryChildAvaliable: false, //是否可以携童
				StartSiteLoction: '', //上车点经纬度
				EndSiteLoction: '', //下车点经纬度
			};
		},
		onLoad(params) {
			_self = this;
			//班次信息
			// 数据格式{"selectDate": "2021/10/26","startStation": "延平","endStation": "南平建阳站"}
			_self.orderInfo = JSON.parse(params.orderInfo);
			// //接口查询字段
			_self.startStation = _self.orderInfo.StartSiteName;
			_self.endStation = _self.orderInfo.EndSiteName;
			console.log('126',_self.orderInfo);
			_self.ExecuteScheduleID = _self.orderInfo.ExecuteScheduleID;

			_self.date = _self.orderInfo.ExecuteDate;
			// console.log(_self.date);
			//设置页面字体大小
			_self.fontSize = app.fontSize;
			_self.currentType = params.type;
			_self.BookType = _self.orderInfo.BookType;
			// _self.getScheduleByID(ExecuteScheduleID);
			//初始化时间轴
			_self.loadDate();
			//将上一个页面传过来的日期设置为被选中状态_self.popDate.replace(/-/g,'/'),
			_self.onSelected(_self.orderInfo.ExecuteDate.split('T')[0].replace(/-/g, '/'));
			//请求班次数据
			//_self.GetCoachInfoBySite(_self.orderInfo.ExecuteDate.split('T')[0].replace(/-/g, '/'));
		},
		onShow() {},
		onUnload() {
			clearInterval(_self.timer);
			clearInterval(_self.checkTicketTimer);
		},
		methods: {
			//-----------------------------------------------Toast 消息提示-----------------------------------------------
			showToast(title, type) {
				_self.$refs.uToast.show({
					title: title,
					type: type,
				})
			},
			/**
			 * 身份证加*号
			 */
			idCardChange(str) {
				if (str == null || str == '') return '';
				return str.substr(0, 2) + '**************' + str.substr(str.length - 2, str.length);
			},
			//-------------------------------时间转换-------------------------------
			timeFormat(date) {
				var setTime = date.split('T')[1];
				return setTime.substring(0, 5);
			},
			getTicketDate: function(date) {
				var setTime = date.replace('T', ' ');
				return setTime.substring(0, 16);
			},
			change(e) {
				this.current = e;
			},
			//--------------------------------------返回--------------------------------------
			goBack() {
				uni.navigateBack();
			},

			//班次下拉选择
			ScheduleClike: function(index) {
				for (let i = 0; i < _self.shiftList.length; i++) {
					if (index == i) {
						_self.shiftList[i].checked = true;
					} else {
						_self.shiftList[i].checked = false;
					}
				}
			},
			ticketSelect: function(index) {
				for (let i = 0; i < _self.shiftList.length; i++) {
					if (index == i) {
						_self.shiftList[i].checked = true;
						console.log('132132132',_self.shiftList[index].SchedulesType);
						for (let i = 0; i < _self.shiftList[index].SchedulesType.length; i++) {
							if (_self.shiftList[index].SchedulesType[i].PriceID.lastIndexOf('02') == _self.shiftList[index]
								.SchedulesType[i].PriceID.length - 2 && _self.ExecuteScheduleID.lastIndexOf('02') == _self
								.ExecuteScheduleID.length - 2) {
								_self.PriceID = _self.shiftList[index].SchedulesType[i].PriceID;
								_self.FreeSeats = _self.shiftList[index].SchedulesType[i].FreeSeats;
							} else {
								_self.PriceID = _self.shiftList[index].SchedulesType[i].PriceID;
								_self.FreeSeats = _self.shiftList[index].SchedulesType[i].FreeSeats;
							}
							uni.showToast({
								title: '请确认改签',
								icon: 'none',
							})
						}
					} else {
						_self.shiftList[i].checked = false;
					}
				}
				
			},
			//--------------------------------------选中--------------------------------------
			ticketTypeSelect: function() {
				uni.showModal({
					title: '',
					content: "正在执行改签操作，确认是否改签!",
					success(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在改签...'
							});
							uni.request({
								url: _self.$h.expressInterface.expressInterface.ChangeSignClick.url,
								method: _self.$h.expressInterface.expressInterface.ChangeSignClick
									.method,
								header: _self.$h.expressInterface.expressInterface.ChangeSignClick
									.header,
								data: {
									freeSeats: _self.FreeSeats,
									bookLogAID: _self.orderInfo.AID,
									executeScheduleID: _self.PriceID,
								},
								success: (res) => {
									uni.hideLoading();
									console.log('0001',res);
									//非空判断
									if (res.data.indexOf('改签成功') != -1 || res.data == '') {
										uni.showToast({
											title: '改签成功',
											icon: 'none',
										})
										setTimeout(function() {
											uni.switchTab({
												url: '../../pages/Order/Order'
											})
										}, 2000)
									} else {
										uni.showToast({
											title: '改签失败:' + res.data,
											icon: 'none',
											duration: 3000
										})
									}
								},
								fail(res) {
									uni.hideLoading();
								}
							});
						}
					}
				})





			},
			//--------------------------------------乘客推荐上车点--------------------------------------
			GetStarSiteNameByLocation: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.url,
					method: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.method,
					header: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.header,
					data: {
						longitude: _self.currentLongitude,
						latitude: _self.currentLatitude,
						midwayLineSites: JSON.stringify(_self.ticketCheck.StartSites),
					},
					success: (res) => {
						uni.hideLoading();
						console.log(res);
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							_self.recommendGeton = res.data.Message;
							_self.ActualStartSiteName = list.SiteName;
							_self.startGeocoderAddress = '';
							_self.endGeocoderAddress = '';
							_self.changeTicketPrice();
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无推荐上车点信息',
								icon: 'none'
							})
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------计算价格--------------------------------------
			countTotalPrice: function() {
				//console.log(_self.ticketCheck);
				if (_self.personArr.length > 0 && _self.ticketCheck) {
					var fullNum = 0;
					var halfNum = 0;
					for (let i = 0; i < _self.personArr.length; i++) {
						if (_self.personArr[i].Type == '成人') {
							fullNum++;
						} else if (_self.personArr[i].Type == '半票儿童') {
							halfNum++;
						}
					}
					_self.totalPrice = _self.FullPrice * fullNum + _self.HalfPrice * halfNum;
				}
			},
			//--------------------------------------显示购票须知--------------------------------------
			showNoticeContent: function() {
				_self.GetTicketInstructionsMemo();
			},
			showInsureContent: function() {
				_self.GetInsureMemo();
			},
			//--------------------------------------加载购票须知--------------------------------------
			GetTicketInstructionsMemo: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('购票须知', res)
						if (res.data.Success) {
							_self.showNotice = true;
							_self.noticeContent = res.data.Data;
							console.log('须知须知', _self.noticeContent);
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			GetInsureMemo: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetInsureMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetInsureMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetInsureMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('保险须知', res)
						if (res.data.Success) {
							_self.showNotice = true;
							_self.noticeContent = res.data.Data;
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------加载购票须知--------------------------------------
			GetTicketInstructionsMemo1: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						// console.log('购票须知',res)
						if (res.data.Success) {
							// _self.showNotice = true;
							_self.noticeContent = res.data.Data;
							console.log('须知须知', _self.noticeContent);
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------记录用户操作--------------------------------------
			GetOperationLog: function(ExecuteDate) {
				var ScheduleLength = 0;
				console.log(_self.shiftList);
				if (_self.shiftList) {
					ScheduleLength = _self.shiftList.length;
				}
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetOperationLog.url,
					method: _self.$h.expressInterface.expressInterface.GetOperationLog.method,
					header: _self.$h.expressInterface.expressInterface.GetOperationLog.header,
					data: {
						StartSiteName: _self.ActualStartSiteName, //起点
						EndSiteName: _self.ActualEndSiteName, //终点
						PhoneNumber: _self.userInfo.PhoneNumber || _self.phone, //用户手机号
						BookType: _self.BookType, //下单类型：城际快车、汽车票
						ExecuteDate: ExecuteDate, //选择班次的日期
						ScheduleLength: ScheduleLength, //返回班次的长度
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						console.log('记录乘客操作返回数据', res);
					},
					fail(res) {
						console.log('记录乘客操作返回数据', res);
					}
				});
			},
			//--------------------------------------客运加载班次列表数据--------------------------------------
			GetCoachInfoBySite: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.url,
					method: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.method,
					header: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						StartSite: _self.startStation,
						EndSite: _self.endStation,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						// console.log(res);
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							for (let i = 0; i < list.length; i++) {
								var arr = {
									checked: false,
									StationName: list[i].StationName,
									EndSiteName: list[i].EndSiteName,
									FullPrice: list[i].FullPrice,
									HalfPrice: list[i].HalfPrice,
									FreeSeats: list[i].FreeSeats,
									SetoutTime: list[i].SetoutTime,
									PriceID: list[i].PriceID,
									LineName: list[i].LineName,
									CompanyCode: list[i].CompanyCode,
									StartSites: list[i].StartSites,
									EndSites: list[i].EndSites,
									PlanCoachCardNumber: list[i].PlanCoachCardNumber,
									LinePrices: list[i].LinePrices,
									HotLine: list[i].Memo,
									CarryChildAvaliable: list[i].CarryChildAvaliable,
									EstimatedTime: list[i].EstimatedTime,
									SchedulesType: list[i].schedulesType,
									Descript: list[i].Descript,
								}
								_self.shiftList.push(arr);
							}
							if (_self.shiftList.length > 0) {
								_self.Price = _self.shiftList[0].FullPrice;
							}
						} else {
							_self.shiftList = [];
							uni.showToast({
								title: res.data.Message,
								icon: 'none'
							})
						}
						//记录用户操作
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------城际快车（有线路id）加载班次列表数据--------------------------------------
			GetScheduleByLineID: function(date, LineID) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.url,
					method: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.method,
					header: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						LineID: LineID,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						// console.log(res);
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							if (list.ScheduleInfos) {
								for (let i = 0; i < list.ScheduleInfos.length; i++) {
									var arr = {
										checked: false,
										StationName: list.ScheduleInfos[i].StationName,
										EndSiteName: list.ScheduleInfos[i].EndSiteName,
										FullPrice: list.ScheduleInfos[i].FullPrice,
										HalfPrice: list.ScheduleInfos[i].HalfPrice,
										FreeSeats: list.ScheduleInfos[i].FreeSeats,
										SetoutTime: list.ScheduleInfos[i].SetoutTime,
										PriceID: list.ScheduleInfos[i].PriceID,
										LineName: list.ScheduleInfos[i].LineName,
										CompanyCode: list.ScheduleInfos[i].CompanyCode,
										StartSites: list.ScheduleInfos[i].StartSites,
										EndSites: list.ScheduleInfos[i].EndSites,
										PlanCoachCardNumber: list.ScheduleInfos[i].PlanCoachCardNumber,
										LinePrices: list.ScheduleInfos[i].LinePrices,
										HotLine: list.ScheduleInfos[i].Memo,
										CarryChildAvaliable: list.ScheduleInfos[i].CarryChildAvaliable,
										EstimatedTime: list.ScheduleInfos[i].EstimatedTime,
										SchedulesType: list.ScheduleInfos[i].schedulesType,
									}
									// if(i==0){
									// 	arr.checked = true;
									// }
									_self.shiftList.push(arr);
								}
								if (_self.shiftList.length > 0) {
									_self.Price = _self.shiftList[0].FullPrice;
								}
							}
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无班次信息',
								icon: 'none'
							})
						}
						//记录用户操作
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------城际快车（无线路id）加载班次列表数据--------------------------------------
			GetScheduleByStarEndSite: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});

				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.url,
					method: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.method,
					header: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						StartSite: _self.orderInfo.startStation,
						EndSite: _self.orderInfo.endStation,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						// console.log(res);
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							console.log('班次信息', list);
							if (list.ScheduleInfos) {
								for (let i = 0; i < list.ScheduleInfos.length; i++) {
									var arr = {
										checked: false,
										StationName: list.ScheduleInfos[i].StationName,
										EndSiteName: list.ScheduleInfos[i].EndSiteName,
										FullPrice: list.ScheduleInfos[i].FullPrice,
										HalfPrice: list.ScheduleInfos[i].HalfPrice,
										FreeSeats: list.ScheduleInfos[i].FreeSeats,
										SetoutTime: list.ScheduleInfos[i].SetoutTime,
										PriceID: list.ScheduleInfos[i].PriceID,
										LineName: list.ScheduleInfos[i].LineName,
										CompanyCode: list.ScheduleInfos[i].CompanyCode,
										StartSites: list.ScheduleInfos[i].StartSites,
										EndSites: list.ScheduleInfos[i].EndSites,
										PlanCoachCardNumber: list.ScheduleInfos[i].PlanCoachCardNumber,
										LinePrices: list.ScheduleInfos[i].LinePrices,
										HotLine: list.ScheduleInfos[i].Memo,
										EstimatedTime: list.ScheduleInfos[i].EstimatedTime,
									}
									_self.shiftList.push(arr);
								}
								if (_self.shiftList.length > 0) {
									_self.Price = _self.shiftList[0].FullPrice;
								}
							}
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无班次信息',
								icon: 'none'
							})
						}
						//记录用户操作
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//-----------------------------------显示时刻表-----------------------------------
			scheduleShow: function() {
				_self.showTimePick = true;
				if (_self.ticketCheck == []) {
					//请求班次信息_self.orderInfo.selectDate：上一个页面传过来的时间
					if (_self.orderInfo.type == '城际快车') {
						if (_self.orderInfo.LineID) {
							//请求班次数据(有线路id)
							_self.GetScheduleByLineID(_self.date, _self.orderInfo.LineID);
						} else {
							_self.GetScheduleByStarEndSite(_self.date);
						}
					} else if (_self.orderInfo.type == '客运') {
						//请求班次数据
						_self.GetCoachInfoBySite(_self.date);
					} else {

					}
				}

			},
			//-----------------------------------拨打热线号码-----------------------------------
			HotLineClick: function(phoneNum) {
				uni.makePhoneCall({
					phoneNumber: phoneNum
				})
			},
			//-----------------------------------点击时间选项卡的时间-----------------------------------
			dateClick: function(e, item) {
				_self.selectIndex = e;
				_self.date = item.longDate;
				_self.GetCoachInfoBySite(_self.date);
			},
			//-----------------------------------显示日历-----------------------------------
			onShowDatePicker: function(type) {
				//先隐藏时刻表，再显示日历（由于层级问题，日历不会显示到最上层，所以显示日历的时候需要先隐藏时刻表）
				_self.showTimePick = false;
				_self.$refs.calendar.open();
			},
			//---------------------------------日期确定---------------------------------
			confirm(params) {
				//在日历确定了时间之后先隐藏日历，再显示时刻表（由于层级问题，日历不会显示到最上层，所以显示日历的时候需要先隐藏时刻表）
				_self.dateShow = false;
				_self.showTimePick = true;
				_self.onSelected(params.fulldate);
			},
			//-----------------------------------选择日期-----------------------------------
			onSelected(calSelectDate) {
				// if (_self.orderInfo.type == '城际快车') {
				// 	if (_self.orderInfo.LineID) {
				// 		//请求班次数据(有线路id)
				// 		_self.GetScheduleByLineID(calSelectDate, _self.orderInfo.LineID);
				// 	} else {
				// 		_self.GetScheduleByStarEndSite(_self.date);
				// 	}
				// }
				// else {
				_self.GetCoachInfoBySite(calSelectDate);
				// }
				if (calSelectDate) {
					var selectDate = calSelectDate.replace(/-/g, '/');
					//从日历选择时间后刷新列表数据
					// _self.getTicketInfo(e.value);
					var IsExist = false;
					for (var i = 0; i < _self.dateArray.length; i++) {
						if ((new Date(_self.dateArray[i].longDate)).getTime() == (new Date(selectDate)).getTime()) {
							IsExist = true;
							_self.selectIndex = i;
							_self.scrollToView = '';
							if (i <= 1) {
								_self.scrollToView = 'view' + (i - 1);
							} else if (i > 6) {
								_self.scrollToView = 'view' + (i + 1);
							} else {
								_self.scrollToView = 'view' + i;
							}
						}
					}
					//判断时间轴上是否存在改日期，不存在则重新绘制
					if (!IsExist) {
						_self.dateArray = [];
						var dateToday = new Date(); //获取今天日期
						var date = new Date(selectDate); //选中的日期
						_self.selectIndex = 0;
						for (var i = 0; i < 8; i++) {
							var mydate = new Date(date.getTime() + 24 * i * 60 * 60 * 1000); //日期一天加一次
							var nowdate = _self.getTime(3, mydate); //获取该日期的缩写  月/日
							var week = _self.getTime(2, mydate); //获取该日期为周几
							var longdate = _self.getTime(0, mydate); //获取 年/月/日
							if (_self.getTime(0, mydate) == _self.getTime(0, dateToday)) {
								week = '今天';
							}
							_self.dateArray.push({
								week: week,
								date: nowdate,
								longDate: longdate,
							});
						}
					}
				}
			},
			//-----------------------------------初始化时间轴-----------------------------------
			loadDate() {
				var date = new Date();
				_self.selectIndex = 0;
				for (var i = 0; i < 8; i++) {
					var mydate = new Date(date.getTime() + 24 * i * 60 * 60 * 1000);
					var nowdate = _self.getTime(3, mydate);
					var week = _self.getTime(2, mydate);
					var longdate = _self.getTime(0, mydate);
					if (mydate.getTime() == date.getTime()) {
						week = '今天';
					}
					_self.dateArray.push({
						week: week,
						date: nowdate,
						longDate: longdate,
					});
				}
			},
			//日期时间转换函数   type 0 年月日 ，1 时分秒 ， 2 星期 ，3 月/日  4几月几日
			getTime: function(type, date1) {
				let date = new Date(date1.getTime()),
					currentDate,
					currentTime,
					sortDate,
					monthAndDay,
					seperator = "/", // 如果想要其他格式 只需 修改这里 
					year = date.getFullYear(),
					month = date.getMonth() + 1,
					weex = date.getDay(),
					day = date.getDate(),
					hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
					minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
					second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// month >= 1 && month <= 9 ? (month = "0" + month) : "";
				// day >= 0 && day <= 9 ? (day = "0" + day) : "";
				//当前 日期
				currentDate = year + seperator + month + seperator + day;
				//当前 时间
				currentTime = hour + ":" + minute + ":" + second;
				sortDate = month + "/" + day;
				monthAndDay = month + "月" + day + "日";
				// 输出格式 为 2018-8-27 14:45:33
				// console.log(currentDate +" "+ currentTime);
				if (type == 0) {
					return currentDate
				} else if (type == 1) {
					return currentTime;
				} else if (type == 2) {
					if (weex == 1) {
						return '周一'
					}
					if (weex == 2) {
						return '周二'
					}
					if (weex == 3) {
						return '周三'
					}
					if (weex == 4) {
						return '周四'
					}
					if (weex == 5) {
						return '周五'
					}
					if (weex == 6) {
						return '周六'
					}
					if (weex == 0) {
						return '周日'
					}
				} else if (type == 3) {
					return sortDate;
				} else if (type == 4) {
					return monthAndDay;
				} else {
					return currentDate + " " + currentTime;
				}
			},
		}
	};
</script>

<style>
	.mg-top-20 {
		margin-top: 20rpx;
	}

	.mg-top-40 {
		margin-top: 40rpx;
	}

	.border-r-20 {
		border-radius: 20rpx;
	}

	.border-r-8 {
		border-radius: 8rpx;
	}

	.v-name {
		border: solid 1rpx #4481eb;
		color: #4481eb;
		padding: 5rpx 20rpx;
		margin-right: 20rpx;
	}

	.v-type {
		background-color: #e3f3ff;
		color: #4481eb;
		padding: 5rpx 8rpx;
		margin-left: 15rpx;
		font-size: 24rpx;
	}

	.checkbox {
		width: 50rpx;
		height: 50rpx;
		border: solid 1rpx #999;
		border-radius: 100%;
		text-align: center;
		line-height: 45rpx;
		/* position: fixed; */
		/* right: 60rpx; */
	}

	.defaultPay {
		background: linear-gradient(270deg, #95a5a6, #ecf0f1);
	}

	.checkbox-activite {
		background: linear-gradient(270deg, #ef7d4e, #ec5249);
		border-color: #ec5249;
	}

	.circle-blue {
		width: 20rpx;
		height: 20rpx;
		border-radius: 100%;
		background-color: #19A0FF;
	}

	.circle-blue-small {
		width: 15rpx;
		height: 15rpx;
		border-radius: 100%;
		background-color: #A2D9FF;
	}

	.headerClass {
		width: 100%;
		background: #FFFFFF;
		height: 109rpx;
		margin-bottom: 10rpx;
		display: flex;
	}

	.scrollClass {
		height: 109rpx;
		width: 86%;
		/* 外层写这俩 */
		white-space: nowrap;
		flex-wrap: nowrap;
	}

	.blockClass {
		margin: 12rpx 14rpx;
		/* background: #FFFFFF; */
		width: 87rpx;
		height: 84rpx;
		border-radius: 8rpx;
		/* 里层写这个 */
		display: inline-block;
	}

	.textCLass {
		margin: 9rpx 17rpx;
	}

	.weekClass {
		/* display: block; */
		/* font-size: 26rpx; */
		font-family: MicrosoftYaHei;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}

	.calendarImage {
		width: 35rpx;
		height: 37rpx;
	}

	.dateClass {
		/* display: block; */
		font-size: 24rpx;
		font-family: MicrosoftYaHei;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}

	.dateselect {
		background: linear-gradient(270deg, #ef7d4e, #ec5249);
	}

	.weekClass {
		color: #FFFFFF;
	}

	.dateClass {
		color: #FFFFFF;
	}
</style>